<?php
/**
 * Created by PhpStorm.
 * User: chenx
 * Date: 18-3-6
 * Time: 下午5:02
 */

namespace common\models;


use yii\db\ActiveRecord;

class Tree extends ActiveRecord
{
    public static function tableName()
    {
        return 'tree';
    }

    public function rules()
    {
        return [
            [['tree_name','icon','parents'],'string'],
            [['id','pid','created_at','updated_at','level'],'integer']
        ];

    }

    public function attributeLabels()
    {
        return [
            'id	'=> 'id',
            'tree_name'=> '分类名称',
            'pid'=> 'pid',
            'parents'=> '所有父级',
            'icon'=> '图标',
            'level'=>'层级',
            'created_at	'=> '创建时间',
            'updated_at'=>'修改时间',
        ];
    }

    public function GetParentInfo($id){
        return $this->find()->where(['pid'=>$id])->asArray()->all();
    }
}